package com.bk.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bk.domain.Collection;
import com.bk.service.CollectionService;
import com.bk.mapper.CollectionMapper;
import com.bk.utils.Result;
import org.springframework.stereotype.Service;

/**
* @author 24940
* @description 针对表【collection】的数据库操作Service实现
* @createDate 2024-04-04 11:19:56
*/
@Service
public class CollectionServiceImpl extends ServiceImpl<CollectionMapper, Collection>
    implements CollectionService{

    @Override
    public Result getCollection(Long id) {
        Collection query = getById(id);
        if (query == null) {
            return Result.error("404", "该合集不存在");
        }
        return Result.success(query);
    }

    @Override
    public Result addCollection(Collection collection) {
        return save(collection)?Result.success():Result.error("500", "添加失败");
    }

    @Override
    public Result deleteCollection(Long id) {
        return removeById(id)?Result.success():Result.error("500", "删除失败");
    }

    @Override
    public Result updateCollection(Collection collection) {
        return updateById(collection)?Result.success():Result.error("500", "删除失败");
    }
}




